home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 637 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: ausnews.austin.ibm.com!usenet
  2. From: mwhitten@vnet.ibm.com (Marc R. Whitten)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Using ARGV on VAX - How?
  5. Date: 5 Jan 1996 14:26:06 GMT
  6. Organization: IBM Dallas Systems Center
  7. Message-ID: <4cjcdu$93i@ausnews.austin.ibm.com>
  8. References: <1996Jan5.094956.1@vax.sbu.ac.uk>
  9. Reply-To: mwhitten@vnet.ibm.com (Marc R. Whitten)
  10. NNTP-Posting-Host: marc.sl.dfw.ibm.com
  11. X-Newsreader: IBM NewsReader/2 v1.02
  12.  
  13. In <1996Jan5.094956.1@vax.sbu.ac.uk>, tonyh@vax.sbu.ac.uk writes:
  14. >Hi out there everyone,
  15. >
  16. >Just a quickie, how do i get VAX to execute the argv 
  17. >command in C.
  18. >
  19. >I include stdio.h and stdlib.h, the file is called myfile.c :
  20. >
  21. >main (int argc, char *argv[])
  22. >{
  23. >    if (argv != 2) {
  24.          // ^^^^^^^^^^^^
  25.          // this is your problem...argc contains the count of items passed from the command line...looks
  26.          // like this is just a typo, I'd imagine. try it with 
  27.  
  28.          // if (argc < 2) { 
  29.          // and everything should be ok.
  30.          
  31.  
  32.  
  33. >     printf("you forgot to enter your name");
  34. >    exit(1);
  35. >    }
  36. >    printf("Hello %s", argv[1]);
  37. >}
  38. >
  39. >when i type exe myfile.c  tony it should produce 'Hello Tony'
  40. >but all i get is :
  41. >
  42. >    "you forgot to enter your name"
  43. >
  44. >can someone email me (if possible) and tell me what I'm doing wrong?
  45. >
  46. >
  47.  
  48. Marc
  49.  
  50.  
  51. These opinions are mine and do not reflect those of the IBM Corporation.
  52.